package nachos.threads;

import nachos.machine.*;

/**
 * A Simple Tester for the KThread class. 
 */
public class KThreadSimpleTest {

    /**
     * Tests whether this module is working.
     */
    public static void runTest() {
    	System.out.println("**** Simple KThread testing begins ****");

      HelloWorld helloWorld1 = new HelloWorld();
      KThread HelloWorldThread1 = new KThread( helloWorld1 );
      HelloWorldThread1.setName( "HelloWorldThread-1" );
      HelloWorldThread1.fork();
      HelloWorld helloWorld2 = new HelloWorld();
      KThread HelloWorldThread2 = new KThread( helloWorld2 );
      HelloWorldThread2.setName( "HelloWorldThread-2" );
      HelloWorldThread2.fork();
        
    	KThread.yield();
	    System.out.println("**** Simple KThread testing ends ****");
    }

    /**
     * A simple Runnable class that prints out "Hello World!" out to the screen.
     */
    private static class HelloWorld implements Runnable {

        /**
         * Print out "Hello World!" to the screen.
         */
        public void run() {
             System.out.println( "Hello World!" );
        }

    }

}

